<template>
	<page-body>
		<view class="page">
			<view class="flex benben-position-layout flex flex-wrap align-center course_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap align-center justify-between flex-sub course_fd0_0'>
					<view class='flex flex-wrap align-center MyPortrayal_fd0_0_c0'>
						<text class='fu-iconfont2  MyPortrayal_fd0_0_c0_c0' @tap.stop="handleJumpDiy" data-type="back"
							data-url="1">&#xE794;</text>
					</view>
					<view class='flex flex-wrap align-stretch justify-center'>
						<text class='course_fd0_0_c1_c0'>{{$t('课程')}}</text>
					</view>
					<view class='flex flex-wrap align-center justify-end course_fd0_0_c0'>
					</view>
				</view>
			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---flex布局flex布局开始-->
<!-- 			<view class="flex benben-flex-layout flex-wrap align-center course_flex_1">
				<view class='flex flex-wrap align-center justify-between flex-sub course_fd1_0'
					@tap.stop="pickerDiy1728288761816=true">
					<text class='course_fd1_0_c0'>{{pagingListPostDataContent['academic_year']}}</text>
					<view class='flex flex-wrap align-center'>
						<text class='course_fd1_0_c1_c0'>{{semester}}</text>
						<text class='fu-iconfont2  course_fd1_0_c1_c1'>&#xe78a;</text>
					</view>
				</view>
			</view> -->

			<!---flex布局flex布局结束-->
			<!--选择器开始 -->
			<benben-picker ref="benbenWritePickerCodepicker2" :visible.sync="pickerDiy1728288761816"
				:options='switchType' v-model="optionsValue" @change="pickerChange" mode='linkage' :mask-show='true'
				:timeout='true' :picker-height='88' :level='2' default-type='value'
				:default-props='{"label":"name","value":"value","children":"children"}'>
				<template #picker-header>
					<view class='flex flex-wrap align-center justify-between course_picker2_0'>
						<text @tap="$refs.benbenWritePickerCodepicker2.cancel()">{{$t('取消')}}</text>
						<text class="course_picker2_011236">{{$t('选择学期')}}</text>
						<text class='course_picker2_0_c2'
							@tap="$refs.benbenWritePickerCodepicker2.pickerConfirm()">{{$t('确认')}}</text>
					</view>
				</template>
			</benben-picker>
			<!--选择器结束 -->
			<!---flex布局flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout" style="margin-top: 32rpx;">
				<view class='flex flex-wrap align-center justify-between course_fd3_0'>
					<template v-for='(item,key0) in List'>
						<view class='flex flex-direction flex-wrap align-center justify-between course_fd3_0_c0'
							@tap.stop="handleJumpDiy" data-type="navigateTo"
							:data-url="`/pages/kc/kcdetail/kcdetail?course=${item.aid}`" :key='key0'>
							<image class='course_fd3_0_c0_c0' mode="aspectFill" :src='item.cover'></image>
							<view class='flex flex-direction flex-wrap align-stretch flex-sub course_fd3_0_c0_c1'>
								<text class='course_fd3_0_c0_c1_c0 hid1'>{{group==1?item.courseplan_name:item.name}}</text>
								<!-- <view class='flex flex-wrap align-center'>
									<text class='course_fd3_0_c0_c1_c1_c0'>{{$t('共')}}</text>
									<text class='course_fd3_0_c0_c1_c1_c1'>{{item.class_period}}</text>
									<text class='course_fd3_0_c0_c1_c1_c0'>{{$t('课时')}}</text>
								</view> -->
							</view>
						</view>
					</template>
					<fu-empty :pagingListLoadedAll="pagingListLoadedAll" :pagingListNoListData="pagingListNoListData"
						:listDataLength="listDataLength" :isLoadInit="isLoadInit"></fu-empty>
				</view>
			</view>

			<!---flex布局flex布局结束-->


		</view>
	</page-body>
</template>
<script>
	import pagingList from '@/common/mixin/paging_list.js';
	import {
		validate
	} from '@/common/utils/validate.js'

	export default {
		components: {},
		mixins: [pagingList],

		data() {
			return {
				group:0,
				"pickerDiy1728288761816": false,
				"minixPagingListsApi": "",
				"pageingListApiMethod": "",
				"allowOnloadGetList": false,
				"List": [],
				"pagingListPostDataContent": {
					'semester': '',
					'academic_year': ""
				},
				"optionsValue": [],
				"semester": '', //学期
				"currentYear": '',
				"switchType": [{
					"name": "",
					"value": "1",
					"children": [{
						"name": "第一学期",
						"value": "1",
					}, {
						"name": "第二学期",
						"value": "2",
					}]
				}]
			};
		},
		computed: {

		},
		watch: {},
		onLoad(options) {
			//获取当前的年份
			this.currentYear = new Date().getFullYear()
			this.switchType[0].name = this.currentYear

			//学期
			const currentMonth = new Date().getMonth() + 1;
			this.optionsValue = currentMonth <= 8 ? "['1', '1']" : "['1', '2']";
			this.semester = currentMonth <= 8 ? '第一学期' : '第二学期';

			//参数
			// this.pagingListPostDataContent['academic_year'] = this.currentYear;
			// this.pagingListPostDataContent['semester'] = currentMonth <= 8 ? '1' : '2';

			//获取更多的年份
			this.getMoreYear(this.switchType, 10)

			//获取数据
			this.getcs6f224689e374Func()
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {
			this.group=uni.getStorageSync('USER_GROUP')
		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			getMoreYear(template, yearsCount) {
				const result = [];
				const currentYear = new Date().getFullYear(); // 例如：2025
				const endYear = currentYear + 1; // 假设模板为“2025-2026”，默认是当前学年

				for (let i = 0; i < yearsCount; i++) {
					const start = endYear - i - 1;
					const end = endYear - i;
					result.push({
						name: `${start}`,
						value: (yearsCount - i).toString(),
						children: template[0].children.map(child => ({
							name: child.name,
							value: child.value
						}))
					});
				}


				this.switchType = result
			},
			pickerChange(val) {
				console.log('999', val);
				this.pagingListPostDataContent['academic_year'] = val.obj.col1.name


				this.pagingListPostDataContent['semester'] = val.value[1]
				this.semester = +val.value[1] === 1 ? '第一学期' : '第二学期'; //显示
				this.getcs6f224689e374Func()
			},
			//APP接口-获取我的课程
			getcs6f224689e374Func() {
				this.minixPagingListsApi = global.apiUrls.post68c9345a8e5b8;
				this.pageingListApiMethod = 'get';
				this.allowOnloadGetList = false;
				this.listData = [];
				this.List = this.listData;
				this.pagingListToggle();
				this.$forceUpdate()

			},
			pagingListPostData() {
				return this.pagingListPostDataContent
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #F8F8F8;
		background-size: 100% auto;
	}

	.course_flex_0 {
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.course_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 700;
		color: #333333;
		line-height: 50rpx;
	}

	.course_fd0_0_c0 {
		// width: 120rpx;
	}

	.course_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.course_flex_1 {
		width: 100vw;
		padding: 24rpx;
	}

	.course_fd1_0_c1_c1 {
		font-size: 14rpx;
		color: rgba(153, 153, 153, 1);
	}

	.course_fd1_0_c1_c0 {
		color: rgba(51, 51, 51, 1);
		margin: 0rpx 16rpx 0rpx 0rpx;
	}

	.course_fd1_0_c0 {
		color: rgba(102, 102, 102, 1);
	}

	.course_fd1_0 {
		background: #ebf3ff;
		border-radius: 16rpx;
		background-size: 100% auto;
		padding: 24rpx;
		height: 93rpx;
	}

	.course_picker2_0_c2 {
		color: #4781f5;
	}

	.course_picker2_0 {
		border-bottom: 1px solid #eee;
		background: #fff;
		padding: 0rpx 32rpx 0rpx 32rpx;
		// line-height: 88rpx;
		height: 110rpx;
		border-radius: 24rpx 24rpx 0rpx 0rpx;
		background-size: 100% auto !important;
	}

	.course_fd3_0_c0_c1_c1_c1 {
		color: rgba(153, 153, 153, 1);
		font-size: 24rpx;
		margin: 0rpx 5rpx 0rpx 3rpx;
	}

	.course_fd3_0_c0_c1_c1_c0 {
		color: rgba(153, 153, 153, 1);
		font-size: 24rpx;
	}

	.course_fd3_0_c0_c1_c0 {
		margin: 16rpx 0rpx 16rpx 0rpx;
		color: rgba(51, 51, 51, 1);
		font-size: 28rpx;
		font-weight: 500;
		line-height: 40rpx;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.course_fd3_0_c0_c1 {
		width: 100%;
		padding: 0rpx 16rpx 0rpx 16rpx;
	}

	.course_fd3_0_c0_c0 {
		width: 100%;
		margin: 0;
		height: 180rpx;
		border-radius: 16rpx 16rpx  0 0 ;
	}

	.course_fd3_0_c0 {
		background: #F7FAFF;
		width: 48%;
		height:250rpx;
		border-radius: 16rpx;
		background-size: 100% auto;
		margin: 0rpx 0rpx 18rpx 0rpx;
	}

	.course_fd3_0 {
		margin: 0rpx 24rpx 0rpx 24rpx;
	}

	//
	.course_picker2_011236 {
		color: rgba(51, 51, 51, 1);
		font-size: 32rpx;
		font-weight: 500;
		line-height: 40rpx;
	}
</style>